package models

import (
	"time"

	"gorm.io/gorm"
)

type Article struct {
	ID uint `json:"id" gorm:"primary_key;auto_increment"`
	// 标题，内容
	Title        string `json:"title" gorm:"size:255;not null"`
	Content      string `json:"content" gorm:"size:255;not null"`
	CoverImage   string `gorm:"size:255" json:"cover_image"`
	State        string `gorm:"type:enum('draft','published','archived');default:'draft'" json:"state"`
	CommentCount int    `gorm:"default:0" json:"comment_count"`

	PublishedAt *time.Time     `json:"published_at"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
}

// 创建文章请求结构体
type CreateArticleRequest struct {
	Title      string `json:"title" binding:"required"`
	Content    string `json:"content" binding:"required"`
	CoverImage string `json:"cover_image"`
	State      string `json:"state"`
	CategoryID *uint  `json:"category_id"`
}
